package main

import (
	"io"
	"log"
	"net/http"
	"os"
)

func main() {
	serverBurl := os.Getenv("SERVER_B_URL")
	if len(serverBurl) == 0 {
		log.Println("没有设置 SERVER_B_URL 环境变量")
		return
	}

	http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
		resp, err := http.Get(serverBurl)
		if err != nil {
			log.Println(err)
			return
		}

		defer resp.Body.Close()
		respBody, _ := io.ReadAll(resp.Body)
		writer.Write(respBody)
	})
	http.ListenAndServe("0.0.0.0:8888", nil)
}
